/**
 * Created by gongxun on 17/1/13.
 */

var GsbdxTableUILayer = GameCCSBase.extend({
    mGsbdxTableMicLayer : null,
    mGsbdxTablePlayerInfoLayer : null,
    mGsbdxTableChatLayer : null,
    mGsbdxTableSettingLayer : null,
    mGsbdxTableEndLayer : null,

    Panel_ready : null,
    Panel_bet : null,
    Panel_otc : null,
    Panel_cardType : null,
    Image_userControlTips : null,
    Panel_playeAnim : null,
    Panel_tip : null,
    Image_ipwarring : null,

    mButton_bets : null,
    mCardTypes : null,
    mPlayer : null,
    mPlayerPoss : null,
    mPlayerInfos : null,

    //网络延迟
    mKwxSysInfoWidget : null,
    Button_kick1 : null,
    Button_kick2 : null,
    Button_kick3 : null,
    Button_kick4 : null,
    ctor : function(){
        this._super();
        this.loadCocostudio("res/ccs/GsbdxTableUI.json");
        this.Panel_ready = mo.seekWidgetByName(this.ccsNode, "Panel_ready");
        this.Panel_bet = mo.seekWidgetByName(this.ccsNode, "Panel_bet");
        this.Panel_otc = mo.seekWidgetByName(this.ccsNode, "Panel_otc");
        this.Panel_cardType = mo.seekWidgetByName(this.ccsNode, "Panel_cardType");
        this.Image_userControlTips = mo.seekWidgetByName(this.ccsNode, "Image_userControlTips");
        this.Panel_playeAnim = mo.seekWidgetByName(this.ccsNode, "Panel_playeAnim");
        this.Panel_tip = mo.seekWidgetByName(this.ccsNode, "Panel_tip");
        this.Button_kick1 = mo.seekWidgetByName(this.ccsNode, "Button_kick1");
        this.Button_kick2 = mo.seekWidgetByName(this.ccsNode, "Button_kick2");
        this.Button_kick3 = mo.seekWidgetByName(this.ccsNode, "Button_kick3");
        this.Button_kick4 = mo.seekWidgetByName(this.ccsNode, "Button_kick4");
        this.Image_ipwarring = mo.seekWidgetByName(this.ccsNode, "Image_ipwarring");

        //设置
        mo.seekWidgetByName(this.ccsNode, "Button_setting").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.mGsbdxTableSettingLayer.setDialog(true);
            }
        }, this);

        //规则
        mo.seekWidgetByName(this.ccsNode, "Button_rule").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.addChild(new GsbdxTableRuleLayer());
            }
        }, this);

        this.loadUI();
    },

    onEnter : function(){
        this._super();

        mo.eventHelper.add("UserChatMsgResponse", this, function(userChatMsgResponse){
            this.setChatMsg(userChatMsgResponse);
        });

        mo.eventHelper.add("UserOnLineChange", this, function(onlineInfo){
            this.setPlayerOnlineStats(onlineInfo);
        });

        mo.eventHelper.add("UserChatMsgResponse_reward", this, function(userChatMsgResponse){
            this.setChatMsgReward(userChatMsgResponse);
        });
    },

    onExit : function(){
        mo.eventHelper.remove(this);
        this._super();
    },

    loadUI : function(){
        if (cc.sys.isNative){
            this.mGsbdxTableMicLayer = new GsbdxTableMicLayer();
            this.addChild(this.mGsbdxTableMicLayer);
        }

        //个人信息
        this.mGsbdxTablePlayerInfoLayer = new KwxTablePlayerInfoLayer();
        this.addChild(this.mGsbdxTablePlayerInfoLayer);

        this.mGsbdxTableChatLayer = new KwxDialogChat();
        this.mGsbdxTableChatLayer.setChatButton(mo.seekWidgetByName(this.ccsNode, "Button_chat"), "gsbdx");
        this.addChild(this.mGsbdxTableChatLayer);

        this.mGsbdxTableSettingLayer = new KwxDialogSetting("gsbdx");
        this.addChild(this.mGsbdxTableSettingLayer);

        this.mGsbdxTableEndLayer = new GsbdxTableEndLayer();
        this.addChild(this.mGsbdxTableEndLayer);

        ///准备
        mo.seekWidgetByName(this.Panel_ready, "Button_start").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.gameMsgManager.sendGameReadyRequestgsbdx();
                // mo.gsbdxTable.showCardWell(mo.gsbdxCardHelper.getRandomCard(10), true);
                // this.intoShowIndex(21);
            }
        }, this);

        mo.seekWidgetByName(this.Panel_ready, "Button_invite").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.gsbdxTable.onInvite();
            }
        }, this);

        mo.seekWidgetByName(this.Panel_ready, "Button_disband").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                var isStart = mo.gsbdxTable.mGameConfig.maxpan != mo.gsbdxTableStatus.mTableStatus.LeftPlayTimes;
                if (!isStart){
                    mo.showMsgDialogOkAndCancel("确定退出房间吗？\n牌局未开始退出不会消耗房卡\n房主退出会解散牌桌", function(){
                        if (mo.gsbdxTable.mGameConfig.maxpan == mo.gsbdxTableStatus.mTableStatus.LeftPlayTimes){
                            mo.gameMsgManager.sendForceExitTableRequestgsbdx();
                        }
                    }, this, function(){}, this);
                }
                // mo.gsbdxTable.mNnTableCancelLayer.sendCancelTableAgree();
            }
        }, this);

        //踢人
        this.Button_kick1.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(1);
            }
        }, this);

        this.Button_kick2.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(2);
            }
        }, this);
        this.Button_kick3.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(3);
            }
        }, this);

        this.Button_kick4.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(4);
            }
        }, this);

        ///下注
        this.mButton_bets = [];
        for(var i = 0; i < 5; i++){
            var Button_bet = mo.seekWidgetByName(this.Panel_bet, "Button_bet" + i);
            this.mButton_bets.push(Button_bet);

            Button_bet.setTag(i);
            Button_bet.addTouchEventListener(function(sender, type){
                if (mo.gameHelper.getIsTouchEnd(type)) {
                    var index = sender.getTag();
                    mo.gsbdxTableStatus.sendMyBet(index);
                    // mo.gsbdxTable.setFapaiAnim([2, 4], 0, null, null, true);
                    // this.intoShowIndex(30);
                }
            }, this);
        }

        //开牌
        mo.seekWidgetByName(this.Panel_otc, "Button_kaipai").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.gsbdxTableStatus.sendKaiPai();
                // mo.gsbdxTable.setKaipaiSeat(0, [42, 44], 6);
                // this.intoShowIndex(31);
            }
        }, this);

        ///牌类型
        this.mCardTypes = [];
        for (var i = 0; i < 5; i++){
            var Panel_cardType = mo.seekWidgetByName(this.Panel_cardType, "Panel_cardType" + i);
            var pos = cc.p(mo.gsbdxCardHelper.seats[i].x, mo.gsbdxCardHelper.seats[i].y + (i == 0 ? 70 : 50));
            Panel_cardType.setPosition(pos);
            var gsbdxTableCardType = new GsbdxTableCardType();
            gsbdxTableCardType.setVisible(false);
            this.mCardTypes.push(gsbdxTableCardType);
            Panel_cardType.addChild(gsbdxTableCardType);
        }

        ///用户
        this.mPlayer = [];
        this.mPlayerPoss = [];
        var Panel_player = mo.seekWidgetByName(this.ccsNode, "Panel_player");
        for(var i = 0; i < 5; i++){
            var player = mo.seekWidgetByName(Panel_player, "Panel_player" + i);
            var playerItem = new GsbdxTablePlayer(i);
            player.addChild(playerItem);
            this.mPlayer.push(playerItem);

            if (i == 0){
                this.mPlayerPoss.push(cc.pAdd(player.getPosition(), cc.p(-227, 35)));
            }else{
                this.mPlayerPoss.push(cc.pAdd(player.getPosition(), cc.p(0, 45)));
            }
        }

        //wifi控件
        this.mKwxSysInfoWidget = new KwxSysInfoWidget();
        mo.seekWidgetByName(this.ccsNode, "Panel_wifi").addChild(this.mKwxSysInfoWidget);
    },

    //控制显示
    //index 1未开始  10:进来的状态 11:结算的状态
    //index 2下注    20:房主下注 21:普通玩家开始下注 22:普通玩家下注后
    //index 3开牌    30:准备开牌 31:等待别人开牌
    intoShowIndex : function(index){
        this.Panel_ready.setVisible(false);
        this.Panel_bet.setVisible(false);
        this.Panel_otc.setVisible(false);
        this.Panel_cardType.setVisible(false);
        this.Image_userControlTips.setVisible(false);

        if (index < 20){
            if (index == 10){
                this.Panel_ready.setVisible(true);
            }else if(index == 11){
                this.Panel_ready.setVisible(true);
                this.Panel_cardType.setVisible(true);

                var Button_start = mo.seekWidgetByName(this.ccsNode, "Button_start");
                var Button_invite = mo.seekWidgetByName(this.ccsNode, "Button_invite");
                var Button_disband = mo.seekWidgetByName(this.ccsNode, "Button_disband");

                //是否打了一局了
                var isPlay = mo.gsbdxTableStatus.mTableStatus.LeftPlayTimes != mo.gsbdxTable.mGameConfig.maxpan;
                Button_invite.setVisible(!isPlay);
                Button_disband.setVisible(!isPlay);

                //自己是否准备
                var myIsReady = mo.gsbdxTableStatus.getMyIsReady();
                if (myIsReady){
                    this.mGsbdxTableEndLayer.setVisible(false);
                }

                //准备按钮显示
                if (!isPlay){
                    //还没有开始
                    if (mo.gsbdxTableStatus.mTableStatus.StartGameSeat == mo.gsbdxTableStatus.mTableStatus.MySeat){
                        //自己是开房负责人
                        Button_start.setVisible(true);
                        Button_start.setEnabled(mo.gsbdxTableStatus.getPlayerCount() >= 2);
                        Button_invite.setPositionX(mo.gameSize.x * 0.25);
                        Button_disband.setPositionX(mo.gameSize.x * 0.75);
                    }else{
                        Button_start.setVisible(false);
                        Button_invite.setPositionX(mo.gameSize.x * 0.35);
                        Button_disband.setPositionX(mo.gameSize.x * 0.65);
                    }
                }else{
                    //已经开始
                    Button_start.setPositionX(mo.gameSize.x / 2);
                    Button_start.setEnabled(true);
                    if (isPlay){
                        Button_start.setVisible(false);
                    }else{
                        Button_start.setVisible(!myIsReady);
                    }
                }

                //处理同ip显示问题
                var ipEquals = mo.gsbdxTableStatus.getPlayerIpEqual();
                if (ipEquals.length > 0 && !isPlay){
                    this.Image_ipwarring.setVisible(true);
                    for (var i = 0; i < 5; i++){
                        var Panel_ip = mo.seekWidgetByName(this.Image_ipwarring, "Panel_ip" + i);
                        if (ipEquals.length > i){
                            Panel_ip.setVisible(true);
                            mo.gameHelper.setTextString(mo.seekWidgetByName(Panel_ip, "Text_ip_nick"), ipEquals[i].nick);
                            mo.gameHelper.setTextString(mo.seekWidgetByName(Panel_ip, "Text_ip_ip"), ipEquals[i].ip);
                        }else {
                            Panel_ip.setVisible(false);
                        }
                    }
                }else{
                    this.Image_ipwarring.setVisible(false);
                }
            }

            //能否显示踢人
            if (mo.gsbdxTableStatus.mTableStatus != null && mo.gsbdxTable.mGameConfig != null){
                var isPlay = mo.gsbdxTableStatus.mTableStatus.LeftPlayTimes != mo.gsbdxTable.mGameConfig.maxpan;
                var funcShowKick = function(viewSeat){
                    if (isPlay){
                        return false;
                    }

                    var logicSeat = mo.gsbdxTableStatus.getLogicForView(viewSeat, mo.gsbdxTableStatus.mTableStatus.MySeat - 1) + 1;
                    return mo.gsbdxTable.mIsRoomCreator && mo.gsbdxTableStatus.mTableStatus["SeatUser" + logicSeat] != null;
                };

                this.Button_kick1.setVisible(funcShowKick(1));
                this.Button_kick2.setVisible(funcShowKick(2));
                this.Button_kick3.setVisible(funcShowKick(3));
                this.Button_kick4.setVisible(funcShowKick(4));
            }

            //关闭倒计时
            this.mPlayer[0].setCloseTime();

        }else if (index < 30){
            if (index == 21){

                this.Panel_bet.setVisible(true);

            }else if (index == 22){

                this.Image_userControlTips.setVisible(true);
                mo.gameHelper.loadTextureImage(this.Image_userControlTips, "res/ccs/gsbdx/tips_xiazhu.png")
            }

            //关闭倒计时
            this.mPlayer[0].setCloseTime();

        }else if (index < 40){
            this.Panel_cardType.setVisible(true);

            if (index == 30){
                this.Panel_otc.setVisible(true);

                if (this.mLastIndex != index){
                    this.mPlayer[0].setStartTime();
                }
            }else if (index == 31){

                this.Image_userControlTips.setVisible(true);
                mo.gameHelper.loadTextureImage(this.Image_userControlTips, "res/ccs/gsbdx/tips_kaipai.png");

                this.mPlayer[0].setCloseTime();
            }
        }

        this.mLastIndex = index;
    },

    //设置牌型
    setKaipaiSeat : function(seat, cardType, isAnim){
        this.mCardTypes[seat].showCardType(cardType, isAnim);
    },

    //重置牌型
    setResetKaipai : function(){
        for (var i = 0; i < this.mCardTypes.length; i++){
            this.mCardTypes[i].setVisible(false);
        }
    },

    //播放买定离手
    setPlayMaidinglishou : function(){
        this.Panel_tip.setVisible(true);
        this.Panel_tip.runAction(cc.sequence(
            cc.delayTime(1),
            cc.hide()
        ));

        var Panel_tipBg = mo.seekWidgetByName(this.Panel_tip, "Panel_tipBg");
        var Image_tip = mo.seekWidgetByName(this.Panel_tip, "Image_tip");

        Panel_tipBg.stopAllActions();
        Panel_tipBg.setScaleY(0.1);
        Panel_tipBg.runAction(cc.sequence(
            cc.scaleTo(0.3, 1)
        ));

        mo.soundHelper.playGsbdxMDLS();

        Image_tip.stopAllActions();
        Image_tip.setPosition(cc.p(-mo.gameSize.x / 2 - 150, 0));
        Image_tip.runAction(cc.sequence(
            cc.moveTo(0.4, cc.p(0, 0)),
            cc.delayTime(0.4),
            cc.moveTo(0.2, cc.p(mo.gameSize.x / 2 + 150, 0))
        ));
    },

    //显示开牌按钮
    showKaipaiBtn : function(isAnim){
        var Button_kaipai = mo.seekWidgetByName(this.Panel_otc, "Button_kaipai");
        Button_kaipai.stopAllActions();
        if (isAnim){
            Button_kaipai.setVisible(false);
            Button_kaipai.runAction(cc.sequence(
                cc.delayTime(4.5),
                cc.show()
            ));
        }else{
            Button_kaipai.setVisible(true);
        }
    },

    //输赢金币动画
    setScoreAnim : function(scores, hostSeat){
        this.Panel_playeAnim.removeAllChildren();

        var delayTime = 1;
        //动画全
        for (var seat = 0; seat < 5; seat++){
            var score = scores[seat];
            if (score == -9999){
                continue;
            }

            this.mPlayer[seat].showAddScoreAnim(score, delayTime);
            if (seat != hostSeat){
                if (score > 0){
                    this.setScoreMovoTo(hostSeat, seat, delayTime);
                }else{
                    this.setScoreMovoTo(seat, hostSeat, delayTime);
                }
            }
        }
        return delayTime + 1;
    },

    //飞金币
    setScoreMovoTo : function(formSeat, toSeat, delayTime){
        var coins = [];
        for (var i = 0; i < 4; i++){
            var coin = new cc.Sprite("res/ccs/gsbdx/gold.png");
            coin.setScale(0.6);
            coin.setVisible(false);
            this.Panel_playeAnim.addChild(coin);

            var posOffset = cc.p(Math.random() * 30 - 15, Math.random() * 30 - 15);
            var formPos = cc.pAdd(this.mPlayerPoss[formSeat], posOffset);
            var toPos = cc.pAdd(this.mPlayerPoss[toSeat], posOffset);
            var distance = cc.pDistance(formPos, toPos);
            var speed = 2000;
            time = distance / speed + i * 0.05 + delayTime;

            coin.setPosition(formPos);
            coin.runAction(cc.sequence(
                cc.delayTime(i * 0.05 + delayTime),
                cc.callFunc(function(){
                    mo.soundHelper.playGsbdxGetCoins();
                }, coin),
                cc.show(),
                cc.moveTo(0.5, toPos),
                cc.hide()
            ));
        }
    },

    //设置牌桌用户信息
    setTablePlayerInfos : function(infos){
        this.mPlayerInfos = infos;
        for (var i = 0; i < 5; i++){
            this.mPlayer[i].setPlayerInfo(infos[i]);
        }
    },

    //chat
    setChatMsg : function(userChatMsg){
        var seat = mo.gsbdxTableStatus.getViewSeatForUid(userChatMsg.uid);
        var Panel_chat = this.mPlayer[seat].Panel_chat;
        Panel_chat.stopAllActions();

        var Image_chat = mo.seekWidgetByName(Panel_chat, "Image_chat");
        var Panel_audio = mo.seekWidgetByName(Image_chat, "Panel_audio");
        var Text_content = mo.seekWidgetByName(Image_chat, "Text_content");
        var Sprite_face = mo.seekWidgetByName(Panel_chat, "Sprite_face");

        Panel_chat.setVisible(false);
        Image_chat.setVisible(false);
        Sprite_face.setVisible(false);
        Panel_audio.setVisible(false);
        Text_content.setVisible(false);

        if (userChatMsg.type == 1){
            //处理文字消息
            var numIndex = parseInt(userChatMsg.msg);

            if (numIndex >=0 && numIndex < 13){
                //播放音效
                var sex = mo.gsbdxTableStatus.getSexForUid(userChatMsg.uid);
                mo.soundHelper.playUserCustom(sex, numIndex);

                //快捷短语
                Text_content.setVisible(true);
                mo.gameHelper.setTextString(Text_content, mo.gameUserInfo.userCustomText[numIndex]);
                var sizeW = Text_content.getContentSize().width + 40;
                sizeW = Math.max(sizeW, 70);
                Text_content.setPositionX(sizeW / 2);

                Panel_chat.setVisible(true);
                Image_chat.setVisible(true);
                Image_chat.setContentSize(cc.size(sizeW, 64));

                Image_chat.runAction(
                    cc.sequence(
                        cc.delayTime(3.0),
                        cc.hide()
                    )
                );
            }else if (numIndex >= 51 && numIndex < 80){

                //表情
                Sprite_face.setVisible(true);
                var animation = new cc.Animation(mo.gsbdxCardHelper.getFaceFrames(numIndex - 51));
                animation.setDelayPerUnit(0.2);
                Sprite_face.stopAllActions();
                Sprite_face.runAction(cc.repeatForever(cc.animate(animation)));

                Panel_chat.setVisible(true);

                Panel_chat.runAction(
                    cc.sequence(
                        cc.delayTime(3.0),
                        cc.hide(),
                        cc.callFunc(function(){
                            Sprite_face.stopAllActions();
                        }, Panel_chat)
                    )
                );
            }else{
                Panel_chat.setVisible(false);

                var formSeat = seat;
                var toSeat = mo.gsbdxTableStatus.getViewForLogic(numIndex % 10, mo.gsbdxTableStatus.mTableStatus.MySeat - 1);
                var index = (parseInt(numIndex / 10) % 10);
                var p1 = this.mPlayerPoss[formSeat];
                var p2 = this.mPlayerPoss[toSeat];

                this.mGsbdxTablePlayerInfoLayer.showEffectChat(formSeat, toSeat, index, p1, p2);
            }
        }else{
            if (!cc.sys.isNative){
                return;
            }

            //语音
            Panel_audio.setVisible(true);

            Panel_chat.setVisible(true);
            Image_chat.setVisible(true);
            Image_chat.setContentSize(cc.size(70, 64));

            //语音信息
            var intArray = [];
            var vmsg = userChatMsg.vmsg;
            var lenght = vmsg.limit - vmsg.offset;
            for (var i = 0; i < lenght; i++){
                intArray.push(vmsg.view[i + vmsg.offset]);
            }

            var millisecond = mo.gameHelper.getMillisecond().toString();
            var fileName = millisecond + ".amr";
            mo.nativeHelper.playFile(fileName, intArray);

            var time = (lenght / 1500);
            Image_chat.runAction(
                cc.sequence(
                    cc.delayTime(time),
                    cc.hide()
                )
            );
        }
    },

    //设置离线状态
    setPlayerOnlineStats : function(onlineInfo){
        //重置
        for (var i = 0; i < 5; i++) {
            this.mPlayer[i].setOnlineStatus(false);
        }

        //设置状态
        if (this.mPlayerInfos != null){
            for (var i = 0; i < 5; i++) {
                if (this.mPlayerInfos[i] == null){
                    continue;
                }
                var uid = this.mPlayerInfos[i].user_info.userid;

                if (onlineInfo[uid.toString()] != undefined && onlineInfo[uid.toString()] == 0){
                    this.mPlayer[i].setOnlineStatus(true);
                }
            }
        }
    },

    //设置录像隐藏
    setIsReplay : function(isReplay){
        mo.seekWidgetByName(this.ccsNode, "Button_setting").setVisible(!isReplay);
        mo.seekWidgetByName(this.ccsNode, "Button_chat").setVisible(!isReplay);
        if (this.mGsbdxTableMicLayer != null){
            this.mGsbdxTableMicLayer.setVisible(!isReplay);
        }
    },

    //设置加倍次数
    setBetInfo : function(newActionList){
        var betBtns = [];
        for (var i = 0; i < 5; i++){
            var btn = this.mButton_bets[i];
            if (i < newActionList.length){
                betBtns.push(btn);
                btn.setVisible(true);
                //多少倍写死了
                var beiNum = newActionList[i].Rate * mo.gsbdxTable.mGameConfig.basepoint;
                var betStr = "res/ccs/gsbdx/btn/bet_" + beiNum +  ".png";
                var Image_text = mo.seekWidgetByName(btn, "Image_text");
                mo.gameHelper.loadTextureImage(Image_text, betStr);
            }else{
                btn.setVisible(false);
            }
        }

        var startP = -(betBtns.length - 1) * 120 / 2;
        for (var i = 0; i < betBtns.length; i++){
            betBtns[i].setPositionX(startP + 120 * i);
        }
    },

    //踢人
    setKickPlayerForViewSeat : function(viewSeat){
        var logicSeat = mo.gsbdxTableStatus.getLogicForView(viewSeat, mo.gsbdxTableStatus.mTableStatus.MySeat - 1) + 1;
        var SeatUser = mo.gsbdxTableStatus.mTableStatus["SeatUser" + logicSeat];
        if (SeatUser != null){
            mo.showMsgDialogOkAndCancel("确定要踢掉玩家[" + SeatUser.user_info.nickname + "]吗?", function(){
                mo.gameMsgManager.sendCreateUserKickOutRequestgsbdx(SeatUser.user_info.userid);
            }, this, function(){}, this);
        }
    },

    //礼包
    setChatMsgReward : function(userChatMsg){
        var kwxRewardLayer = new KwxRewardLayer();
        this.addChild(kwxRewardLayer);
        var toPlayer = mo.gsbdxTableStatus.getViewSeatForUid(userChatMsg.uid);
        kwxRewardLayer.startAction(userChatMsg.msg, this.mPlayerPoss[toPlayer], toPlayer);
    }
});